Installation of rgee step by step in the differents Operative System
In this post, you going to learn to install rgee in the different Operative Systems steps by steps. Remind is necessary to have previously install R, Rtools and Rstudio in your desktop, here in the following video show the steps to be taken for a proper installation.
| - Rtools only is necesarry for the Operative Systen Windows. |
🔴 1. rgee in a Linux distribution
For a distribution like Ubuntu and theirs derivatives is necesarry to have set-up and installed some dependences of spatial libs our Operative System. The following bash commands should install key geographic R packages on Ubuntu 20.10.
# install system dependencies:
sudo apt install libudunits2-dev libgdal-dev libgeos-dev libproj-dev libfontconfig1-dev libjq-dev libprotobuf-dev protobuf-compiler
# binary versions of key R packages:
sudo apt install r-cran-rgee r-cran-geojsonio
For a distribution like Manajaro, Archilinux o derivatives, the installation is using the following bash commands
# install system dependencies:
sudo pacman -S gcc-fortan gdal proj geos
git clone https://aur.acrhlinux.org/udunits.git
cd udunits
makepkg -si
# Starting with R
R
# Installation of rgee and geojsonio:
install.packages("rgee")
install.packages("geojsonio")
Set-up of rgee and register of credentiales
rgee depends on the Python packages numpy and ee, for its installation there are two methods, however we have used the most recommended way for new users without experience in handling the Python virtual environment.
For the installation of rgee dependences use for once only, the following function:
rgee::install_ee()After of the installation of the rgee dependences is necessary to have a registered acount on Google Earth Engine.
| - For register on Google Earth Engine only is necesarry to have a acount of gmail and answer short questions. |
Finally with your acount of gmail registered, you can authenticate and initialize in the Earth Engine R API.
🔴 2. Instalacion on Windows
On windows the installation of rgee is accessible, but you need to have installed miniconda or anaconda, remind that rgee uses python3. For a perfect installation on Windows is necessary activate the reticulate library in your R sesion together rgee.
# Installation of rgee and geojsonio:
install.packages("rgee")
install.packages("geojsonio")# Activation of packages:
library(rgee)
library(reticulate)The py_discover_config() function of reticulate package we allow to know the version of python that will to be used for the installation of Packages numpy and ee.
> py_discover_config()
python: C:/Users/Windows 10/anaconda3/python.exe
libpython: C:/Users/Windows 10/anaconda3/python39.dll
pythonhome: C:/Users/Windows 10/anaconda3
version: 3.9.7 (default, Sep 16 2021, 16:59:28) [MSC v.1916 64 bit (AMD64)]
Architecture: 64bit
numpy: C:/Users/Windows 10/anaconda3/Lib/site-packages/numpy
numpy_version: 1.20.3
| - The function py_config() we allow list all version of python discovered in our System. |
Having identified the python version, the next step is to set the path as the new Python environment for rgee, for this we use the following function use_python(“PUT-HERE-THE-PYTHON3-VERSION-PATH”)
use_python("C:/Users/Windows 10/anaconda3/python.exe")
You can verify the selection of python to work with rgee.
> py_config()
python: C:/Users/Windows 10/anaconda3/python.exe
libpython: C:/Users/Windows 10/anaconda3/python39.dll
pythonhome: C:/Users/Windows 10/anaconda3
version: 3.9.7 (default, Sep 16 2021, 16:59:28) [MSC v.1916 64 bit (AMD64)]
Architecture: 64bit
numpy: C:/Users/Windows 10/anaconda3/Lib/site-packages/numpy
numpy_version: 1.20.3
ee: [NOT FOUND]
NOTE: Python version was forced by use_python function
Finally, we set up our rgee environment, install the necessary python dependencies, then initialise Google Earth Engine from R and save our credentials.
🔴 2. Instalacion on Mac OS
Installation on Mac OS is very similar to a GNU/Linux distribution, in the following code section, we share the codes and some screenshots of some key points to consider.
# Installation of rgee and geojsonio:
install.packages("sf")
install.packages("geojsonio")# Installation of Python dependence libraries:
rgee::install_ee()